package STUDENT.TRANBANGTUNG.day_05_04_2016;

import java.util.Scanner;

public class caculator {
	public static void main(String[] args) {

		String a1;

		String b1;
		String tinh;
		double c;
		System.out.println("nhap so a!");
		Scanner sca = new Scanner(System.in);
		a1 = sca.nextLine();
		if (a1.isEmpty()) {
			System.out.println("vui long nhap a!");
		} else {
			double a = Double.parseDouble(a1);
			System.out.println("nhap so b!");
			Scanner scb = new Scanner(System.in);
			b1 = sca.nextLine();
			if (b1.isEmpty()) {
				System.out.println("vui long nhap so b!");
			} else {
				double b = Double.parseDouble(b1);
				System.out.println("nhap phep tinh cong,tru,nhan,chia!");
				Scanner sctinh = new Scanner(System.in);
				tinh = sca.nextLine();
				if (tinh.isEmpty()) {
					System.out.println("vui long nhap phep tinh cong,tru,nhan,chia");
				} else {
					if (tinh.equals("cong")) {
						c = a + b;
						System.out.println("gia tri la: " + c);
					} else if (tinh.equals("tru")) {
						c = a - b;
						System.out.println("gia tri la: " + c);
					} else if (tinh.equals("nhan")) {
						c = a * b;
						System.out.println("gia tri la: " + c);
					} else if (tinh.equals("chia")) {
						if (b == 0) {
							System.out.println("phep tinh loi vi b =0");
						} else {
							c = a / b;
							System.out.println("gia tri la: " + c);
						}
					}

				}
			}
		}

	}
}
